/*
 * Placement - The interface for placing walls and towers (vs. gameplay rules)
 *
 * Copyright 2007 James W. Hofmann
 *
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

#if flash9
import flash.events.TimerEvent;
import flash.Lib;
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.display.Graphics;
import flash.display.Shape;
import flash.display.BitmapData;
import flash3f.InputHandler;
import flash3f.Images;
import flash.geom.Point;
#else neko
import neko3f.InputHandler;
import lib3f.Point;
#end
import lib3f.IntPoint;
import lib3f.Dist;

class Placement
{


	public static function confirm()
	{
		FortressManager.confirm();
	}
	
	public static function start()
	{
	}

	public static function up()
	{

		var newfort : FortressData;
		
		if (InputHandler.click)
		{
		
			if (Graph.inbounds(HUD.ctx, HUD.cty, Game.cur.map) && 
			Game.cur.map[HUD.ctx][HUD.cty].fort!=null && 
			Game.cur.map[HUD.ctx][HUD.cty].fort.shooter!=null &&
			Gameplay.placetype==1)
			{
				var cur = Game.cur.map[HUD.ctx][HUD.cty];
				if (cur.fort.shooter.weapon==1)
				{

					cur.fort.upgradekill();

					newfort = FortressManager.add(HUD.ctx, HUD.cty, 3);
					newfort.shooter = new Shooter(Gameplay.upgradetype,
					newfort);

					FortressSprite.refreshall();
				}
			}
			else
			{

				if (Gameplay.placetype==0)					
					newfort = FortressManager.add(HUD.ctx, HUD.cty, 1);
				else	
					newfort = FortressManager.add(HUD.ctx, HUD.cty, 3);
				if (newfort!=null)
				{
					var newspr = new FortressSprite(newfort);
					newspr.drawangle();
				}
			}
		}				
		
		
	}

}
